package com.ztgf.sys.api.cms;

import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import com.ztgf.sys.models.service.ISysUserRoleRelationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

/**
 * 用户角色关系表控制器
 *
 * @author YUE
 * @Date 2020-05-27 17:39:19
 */

@RestController
@RequestMapping("/cms/sysUserRoleRelation")
@Slf4j
@Api(value = "SysUserRoleRelationController",tags = "用户角色关系表接口")
public class SysUserRoleRelationController {

    @DubboReference
    private ISysUserRoleRelationService sysUserRoleRelationService;

    @ApiOperation(value = "添加用户角色关系表",notes = "添加用户角色关系表")
    @PostMapping(value = "/insert")
    public Result insert(String roleIds,Long userId) {
        if(null == userId){
            return new Result(CodeEnum.FAIL_100002);
        }
        sysUserRoleRelationService.insertOrUpdate(Arrays.asList(roleIds.split(",")),userId);
        return new Result<>();
    }

}
